from PySide2 import QtCore
from PySide2.QtWidgets import QVBoxLayout

import share
from elementUI.h5_element import WebEngineView


class sql_configuration:
    def __init__(self):
        self.ui = share.SI.main.ui

    # 加载SQL配置界面
    def to_load(self,id,name):
        url = "file:///static/pages/SQLTableNew.html?token=" + share.token.headers["Authorization"] + "&tid=" + str(id) + "&tname=" + name

        try:
            self.ui.webbrowser2.load(QtCore.QUrl(url))
        except Exception as e:
            vLayout = QVBoxLayout()
            webbrowser = WebEngineView()
            webbrowser.load(QtCore.QUrl(url))
            self.ui.webbrowser2 = webbrowser
            vLayout.addWidget(webbrowser)
            vLayout.setContentsMargins(5, 2, 5, 2)
            self.ui.sql_widget.setLayout(vLayout)

        self.ui.stackedWidget.setCurrentIndex(12)